package com.appspot.moviesessions.interfaces.webapp.dto;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.apache.commons.lang.builder.ToStringBuilder;

@XmlRootElement(name = "movie")
@XmlType(propOrder = { "id", "name" })
public class Movie {

	@XmlAttribute
	private Long id;

	@XmlAttribute
	private String name;

	@XmlAttribute
	private String rated;

	@XmlAttribute
	private String genre;

	@XmlAttribute
	private String director;

	@XmlAttribute
	private String writer;

	@XmlAttribute
	private String actors;

	@XmlAttribute
	private String plot;

	@XmlAttribute
	private String poster;

	@XmlAttribute
	private String runtime;

	@XmlAttribute
	private String rating;

	@XmlAttribute
	private String votes;

	public static Movie fromMovie(com.appspot.moviesessions.model.Movie movie) {
		Movie dto = new Movie();
		dto.name = movie.getName();
		dto.id = movie.getId();
		dto.rated = movie.getRated();
		dto.genre = movie.getGenre();
		dto.director = movie.getDirector();
		dto.writer = movie.getWriter();
		dto.actors = movie.getActors();
		dto.plot = movie.getPlot();
		dto.poster = movie.getPoster();
		dto.runtime  = movie.getRuntime();
		dto.rating = movie.getRating();
		dto.votes = movie.getVotes();
		return dto;
	}

	public String getName() {
		return name;
	}

	public Long getId() {
		return id;
	}

	public String getRated() {
		return rated;
	}

	public String getGenre() {
		return genre;
	}

	public String getDirector() {
		return director;
	}

	public String getWriter() {
		return writer;
	}

	public String getActors() {
		return actors;
	}

	public String getPlot() {
		return plot;
	}

	public String getPoster() {
		return poster;
	}

	public String getRuntime() {
		return runtime;
	}

	public String getRating() {
		return rating;
	}

	public String getVotes() {
		return votes;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

}
